package com.manor.main.dialog

import android.content.Context
import android.text.method.ScrollingMovementMethod
import com.lxj.xpopup.core.CenterPopupView
import com.lxj.xpopup.util.XPopupUtils
import com.manor.common.utils.SpUtil
import com.manor.common.utils.SpUtils
import com.manor.main.R
import kotlinx.android.synthetic.main.dialog_notice_tips.view.*
import kotlin.math.roundToInt

/**
 *


 * @date  2020/5/18  14:51
 * @version 1.0
 */
class NoticeTipPopup (context: Context, val content: String, val num: Int = 0) : CenterPopupView(context) {

    override fun getImplLayoutId(): Int {
        return R.layout.dialog_notice_tips
    }

    override fun onCreate() {
        super.onCreate()
        SpUtils.getInstance(context).setInt(SpUtil.APP_MAIN_SWITCH, num)
        tvContent.text = content + "\n"
        tvContent.movementMethod = ScrollingMovementMethod.getInstance()
        ivDismiss.setOnClickListener { dismiss() }
        tvConfirm.setOnClickListener { dismiss() }
    }


    override fun getMaxHeight(): Int {
        return (XPopupUtils.getWindowHeight(context) * .80f).roundToInt()
    }

    override fun getMaxWidth(): Int {
        return (XPopupUtils.getWindowWidth(context) * .80f).roundToInt()
    }

}